// json转换辅助工厂，把json转为T


import '../data/consultation_data.dart';
import '../data/family_user_data.dart';
import '../data/login_data.dart';
import '../data/user_login.dart';

class EntityFactory {
  static T? generateOBJ<T>(json) {
    if (json == null) {
      if (T.toString() == "String") {
        return "" as T;
      }
      return null;
    } else if (T.toString() == "UserLogin") {
      final res = UserLogin.fromJson(json) as T;
      return res;
    } else if (T.toString() == "LoginData") {
      final res = LoginData.fromJson(json) as T;
      return res;
    } else if (T.toString() == "ConsultationData") {
      final res = ConsultationData.fromJson(json) as T;
      return res;
    } else if (T.toString() == "FamilyUserData") {
      final res = FamilyUserData.fromJson(json) as T;
      return res;
    } else {
      return json as T;
    }
  }
}
